﻿using BoriPeter.FitnessJournal8.Models;
using Caliburn.Micro;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BoriPeter.FitnessJournal8.ViewModels
{
    public class DailyEntryViewModel : ViewModelBase
    {
        #region Constructor
        public DailyEntryViewModel(INavigationService navigationService)
            : base(navigationService)
        {

        }
        #endregion

        #region Entry
        private DailyEntry entry;
        public DailyEntry Entry
        {
            get
            {
                return this.entry;
            }

            set
            {
                this.entry = value;
                NotifyOfPropertyChange("Entry");
            }
        }
        #endregion

        #region Date
        private DateTime date;

        private string paramDate;
        public string ParamDate
        {
            get { return paramDate; }
            set 
            { 
                paramDate = value;
                date = DateTime.Parse(value);
            }
        }

        #endregion

        #region SelectedFoodEntry
        private FoodEntry selectedFoodEntry;
        public FoodEntry SelectedFoodEntry
        {
            get
            {
                return this.selectedFoodEntry;
            }

            set
            {
                this.selectedFoodEntry = value;
                NotifyOfPropertyChange("SelectedFoodEntry");
                Navigate2FoodDetails(selectedFoodEntry.Food);
            }
        }
        #endregion

        #region OnInitialize()
        protected override async void OnInitialize()
        {
            base.OnInitialize();
            Entry = await NutritionSource.GetDailyEntryAsync(date);
        }
        #endregion
    }
}
